package com.weizai.carshop.controller;


import com.weizai.carshop.common.enumeration.AppHttpCodeEnum;
import com.weizai.carshop.common.result.PageResult;
import com.weizai.carshop.common.result.ResponseResult;
import com.weizai.carshop.model.dto.QueryShopCateDto;
import com.weizai.carshop.model.dto.ShopCateDto;
import com.weizai.carshop.service.ShopCateService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/admin/shopCate/list")
@RequiredArgsConstructor
public class ShopCateController {


    private final ShopCateService shopCateService;

    /*
    * 新增分类
    * */
    @PostMapping
    public ResponseResult insert(@RequestBody ShopCateDto dto) {
        shopCateService.insert(dto);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }

    /*
    * 分页查询分类
    * */
    @GetMapping
    public ResponseResult getShopCateList(QueryShopCateDto dto) {
        PageResult result = shopCateService.queryPage(dto);
        return ResponseResult.okResult(result);
    }

    /*
    * 删除分类接口
    * */
    @DeleteMapping("/{id}")
    public ResponseResult delCate(@PathVariable Long id) {
        ResponseResult result =  shopCateService.delCateById(id);
        return result;
    }
}
